package com.wc.算法提高课.C第三章_图论.拓扑排序.奖金;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/20 13:46
 * @description https://www.acwing.com/problem/content/1194/
 */
public class Main {
    /**
     * 贪心, 拓扑排序, 肯定是最少的那个是100,  然后比他高的101
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 10010, M = 20010;
    static int[] h = new int[N], e = new int[M], ne = new int[M];
    static int[] money = new int[N], din = new int[N], q = new int[N];
    static int n, m, idx = 1;

    public static void main(String[] args) {
        n = sc.nextInt();
        m = sc.nextInt();
        while (m-- > 0) {
            int a = sc.nextInt(), b = sc.nextInt();
            add(b, a);
            din[a]++;
        }
        topsort();
        int res = 0;
        for (int i = 1; i <= n; i++) {
            if (money[i] == 0) {
                res = -1;
                break;
            }
            res += money[i];
        }
        out.println(res == -1 ? "Poor Xed" : res);
        out.flush();
    }

    static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }

    static void topsort() {
        int hh = 0, tt = 0;
        for (int i = 1; i <= n; i++) {
            if (din[i] == 0) {
                q[tt++] = i;
                money[i] = 100;
            }
        }
        while (hh < tt) {
            int t = q[hh++];
            for (int i = h[t]; i > 0; i = ne[i]) {
                int j = e[i];
                if (--din[j] == 0) {
                    money[j] = money[t] + 1;
                    q[tt++] = j;
                }
            }
        }
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
